import Mock from 'mockjs'

// 查询用户列表
export const getUserPage = async (params: User & pagination): Promise<User & pagination> => {
  const res = await Mock.mock({
    'list|10': [
      {
        'id|+1': 1,
        nickName: '@cname',
        avatar: "@image('200x200', '#50B347', '#FFF', 'Mock.js')",
        name: '@word(6, 12)',
        mobile: 14763957234,
        gender: 1,
        cartype: 'C1',
        comment: '@word(6, 12)',
        createTime: '@datetime',
        openid: '@word(6, 12)'
      }
    ],
    pageNo: 1,
    pageSize: 10,
    total: 30
  })
  return res
}

// 查询用户详情
export const getUser = async (id: number): Promise<User> => {
  const res = await Mock.mock({
    'id|+1': 1,
    nickName: '@cname',
    avatar: "@image('200x200', '#50B347', '#FFF', 'Mock.js')",
    name: '@word(6, 12)',
    mobile: 14763957234,
    gender: 1,
    cartype: 'C1',
    comment: '@word(6, 12)',
    createTime: '@datetime',
    openid: '@word(6, 12)'
  })
  return res
}

// 修改用户
export const updateUser = async (data: User): Promise<ResStatus> => {
  return await Mock.mock({
    isSuccess: true
  })
}

// 删除用户
export const deleteUser = async (id: number): Promise<ResStatus> => {
  return await Mock.mock({
    isSuccess: true
  })
}

// 获取短信模板列表system_sms_template
export const getSmsTemplate = async (): Promise<SmsTemplate[]> => {
  const res = await Mock.mock({
    list: [
      {
        id: 1,
        name: '验证码',
        content: '您的验证码是：${code}，请不要${name}把验证码泄露给其他人。',
        code: 'SMS_0000001',
        type: '数字微驾'
      },
      {
        id: 2,
        name: '通知',
        content: '您asdasdasda：${code}，请不要${name}把验证码${address}泄露给其他人。',
        code: 'SMS_000asdasda1',
        type: '数字微驾'
      }
    ]
  })
  return res
}

// 批量发送短信(选取了用户)
export const sendBatchSmsFromUser = async (params: SmsParams): Promise<ResStatus> => {
  const res = await Mock.mock({
    isSuccess: true
  })
  return res
}

// 批量发送短信(没有选取用户)
export const sendBatchSmsFromQuery = async (params: NotCheckSmsParams): Promise<ResStatus> => {
  const res = await Mock.mock({
    isSuccess: true
  })
  return res
}

// 获取公众号模板列表system_mp_template
export const getMpTemplate = async (): Promise<MpTemplate[]> => {
  const res = await Mock.mock({
    data: [
      {
        type: 1,
        name: '模板消息',
        list: [
          {
            id: 1,
            type: 1,
            priTmplId: 'id_0000001',
            title: '@cname',
            content: '会议时间:{{date2.DATA}}\n会议地点:{{thing1.DATA}}\n',
            url: 'http://weixin.qq.com/download',
            miniProgramAppid: 'wx123123123123123',
            miniProgramPagePath: 'pages/index/index'
          },
          {
            id: 2,
            type: 1,
            priTmplId: 'aaaid_0000001',
            title: '@cname',
            content: '会asdasda议时间:{{date2.DATA}}\n会议asdasdas地点:{{thing1.DATA}}\n',
            url: 'http://weixin.qq.com/download',
            miniProgramAppid: 'wx123123123123123asdasda',
            miniProgramPagePath: 'pages/index/index/asdasd'
          }
        ]
      },
      {
        type: 2,
        name: '订阅消息',
        list: [
          {
            id: 1,
            type: 2,
            priTmplId: 'id_0000001',
            title: '@cname',
            content: '会议时间:{{date2.DATA}}\n会议地点:{{thing1.DATA}}\n',
            url: 'http://weixin.qq.com/download',
            miniProgramAppid: 'wx123123123123123',
            miniProgramPagePath: 'pages/index/index'
          },
          {
            id: 2,
            type: 2,
            priTmplId: 'aaaid_0000001',
            title: '@cname',
            content: '会asdasda议时间:{{date2.DATA}}\n会议asdasdas地点:{{thing1.DATA}}\n',
            url: 'http://weixin.qq.com/download',
            miniProgramAppid: 'wx123123123123123asdasda',
            miniProgramPagePath: 'pages/index/index/asdasd'
          }
        ]
      }
    ]
  })
  return res
}

// 批量发送模板消息(选取了用户)
export const sendTemplateFromUser = async (params: MpTemplateParams): Promise<ResStatus> => {
  const res = await Mock.mock({
    isSuccess: true
  })
  return res
}

// 批量发送模板消息(没有选取用户)
export const sendTemplateFromQuery = async (
  params: NotCheckMpTemplateParams
): Promise<ResStatus> => {
  const res = await Mock.mock({
    isSuccess: true
  })
  return res
}
